//
//  SinaTabBarViewController.swift
//  weibo
//
//  Created by liuchao on 16/1/20.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class SinaTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        //UITabBar.appearance().tintColor=UIColor.orangeColor()
        
        
        addChildViewController()
        
        let tabbar=SinaTabBar()
        
        ///Cannot assign to property: 'tabBar' is a get-only property（相当于:tabBar=tabbar）
        setValue(tabbar, forKey: "tabBar")
        
       tabbar.componetButton.addTarget(self, action: "publich", forControlEvents: UIControlEvents.TouchUpInside)
        
    }
    
    func publich(){
    
      print("hehehe-----> 自定义按钮")
        
    }

    func addChildViewController() {
        
        addChildViewController(SinaHomeViewController(), title: "首页", image: "tabbar_home")
        addChildViewController(SinaMessageViewController(), title: "消息", image: "tabbar_message_center")
        addChildViewController(SinaFindViewController(), title: "发现", image: "tabbar_discover")
        addChildViewController(SinaSettingViewController(), title: "设置", image: "tabbar_profile")
    }
    
    
    func addChildViewController(childController: UIViewController,title:String,image:String) {
        
        
        let home=childController
        home.title=title
        home.tabBarItem.image=UIImage(named: image)
        //这句话的作用是？？
        home.tabBarItem.selectedImage=UIImage(named: "\(image)_highlighted")
        
        
        let nav=UINavigationController(rootViewController: home)
        // 添加到控制器里
        addChildViewController(nav)
    }

}
